/*
 * Copyright (C) 2011 JiangHongTiao <jjurco.sk_gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package sk.lieskove301.jianghongtiao.math.statistic.distributions;

import sk.lieskove301.jianghongtiao.liaad.prisoner.gene.GeneEnum;
import sk.lieskove301.jianghongtiao.liaad.prisoner.gene.GeneFunction;

/**
 *
 * @author JiangHongTiao <jjurco.sk_gmail.com>
 */
public class DistributionsForRPlot {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        System.out.println("par(mfrow=c(2,3))");
        for (int i = 0; i < GeneEnum.values().length; i++) {
            GeneEnum geneEnum = GeneEnum.values()[i];
            System.out.print(geneEnum.name() + "<-c(");
            String num = "";
            String coop = "";
            for (int j = 0; j < 1500; j++) {
                int number = (int) (GeneFunction.getUniformNumber(geneEnum)*100);
                int cooperate = (GeneFunction.cooperateByGene(geneEnum))?1:0;
                num += number + ",";
                coop += cooperate + ",";
            }
            System.out.println(num.substring(0, num.length()-1)+")");
            String cab = "Betray and Cooperate";
            System.out.println("\""+cab+"\"<-c(" + coop.substring(0, coop.length()-1)+")");
            System.out.println("\"Sorted "+geneEnum.name() + "\"<-sort("+geneEnum.name()+")");
            System.out.println("plot("+geneEnum.name()+")");
            System.out.println("plot("+"`Sorted "+geneEnum.name()+"`)");
            System.out.println("plot("+"`"+cab+"`)"); //decisions: cooperate/betray
            System.out.println("abline(h=mean(`"+cab+"`), col=\"blue\")"); //abline
        }
        
        for (int i = 0; i < GeneEnum.values().length; i++) {
            GeneEnum geneEnum = GeneEnum.values()[i];
            System.out.println(geneEnum.name()+" distribution");
        }
    }
}
